#define _CRT_SECURE_NO_WARNINGS
#include"sort.h"

void count_sort(array<int, 10>& arr)
{
	int max = arr[0];
	int min = arr[0];
	int i;
	for (i = 0; i < 10; i++)
	{
		if (max < arr[i])
			max = arr[i];
		if (min > arr[i])
			min = arr[i];
	}
	int range = max - min + 1;
	int* count = new int[range];
	fill(count, count + range, 0);
	for (i = 0; i < 10; i++)
	{
		count[arr[i] - min]++;
	}
	int j = 0;
	for (i = 0; i < range; i++)
	{
		if ( count[i]--)
		arr[j++] = i + min;
	}
}